package com.yonyou.brigade.third_parties.didi.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yonyou.brigade.third_parties.didi.model.DidiInvoiceHistory;
import com.yonyou.brigade.third_parties.didi.model.DidiInvoiceOrderHistory;
import com.yonyou.brigade.third_parties.didi.service.IDidiInvoiceHistoryService;
import com.yonyou.brigade.third_parties.didi.service.IDidiInvoiceOrderHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 滴滴开票历史 前端控制器
 * </p>
 *
 * @author kangfw5@yonyou.com
 * @since 2019-07-10
 */
@RestController
@RequestMapping("/third/didi/invoice")
public class DidiInvoiceHistoryController {
    @Autowired
    private IDidiInvoiceHistoryService didiInvoiceHistoryService;
    @Autowired
    private IDidiInvoiceOrderHistoryService didiInvoiceOrderHistoryService;

    /**
     * 查询开票历史
     *
     * @param current  当前页
     * @param size     页大小
     * @param tenantId 租户ID
     * @param phone    手机号
     * @return
     */
    @RequestMapping(value = "/history", method = RequestMethod.GET)
    public Page getInvoiceHistory(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String tenantId, String phone) {


        Page<DidiInvoiceHistory> page = new Page<>(current, size);

        return didiInvoiceHistoryService.queryInvoiceHistoryWithPage(page, tenantId, phone);
    }

    @RequestMapping(value = "/reSendEmail" , method = RequestMethod.GET)
    public Map<String, String> reSendInvoiceInfo(@RequestParam String tenantId, String phone, String invoiceId){
       return   didiInvoiceHistoryService.reSendEmail(tenantId, phone, invoiceId);
    }


    /**
     * 获取开票行程明细
     *
     * @param current   当前页
     * @param size      页大小
     * @param invoiceId 发票ID
     * @return
     */
    @RequestMapping(value = "/detailHistory", method = RequestMethod.GET)
    public Page getInvoiceOrderHistory(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String invoiceId) {
        Page<DidiInvoiceOrderHistory> pg = new Page<>(current, size);

        return didiInvoiceOrderHistoryService.queryInvoiceOrderWithPageByInvoiceId(pg, invoiceId);
    }

    /**
     * 获取发票地址
     *
     * @param tenantId  租户ID
     * @param phone     手机号
     * @param invoiceId 发票ID
     * @return
     */
    @RequestMapping(value = "/getInvoiceAddress", method = RequestMethod.GET)
    public String getInvoiceAddress(String tenantId, String phone, String invoiceId) {
        return didiInvoiceHistoryService.getInvoiceAddress(tenantId, phone, invoiceId);
    }

    /**
     * 获取行程单地址
     *
     * @param tenantId  租户ID
     * @param phone     手机号
     * @param invoiceId 发票ID
     * @return
     */
    @RequestMapping(value = "/getItineraryAddress", method = RequestMethod.GET)
    public String getItineraryAddress(String tenantId, String phone, String invoiceId) {
        return didiInvoiceHistoryService.getItineraryAddress(tenantId, phone, invoiceId);
    }
}

